package com.peak.distribution.entity.order;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;

import com.peak.distribution.entity.goods.DisGoods;
import com.peak.distribution.enums.Constants;
import com.peak.spring.boot.api.entity.LogicalDeleteEntity;

import lombok.Data;
import lombok.EqualsAndHashCode;

@Entity
@Table(name = "dis_order_goods")
@Data
@EqualsAndHashCode(callSuper=true)
public class DisOrderGoods extends LogicalDeleteEntity {
	
	private static final long serialVersionUID = Constants.DISTRIBUTION_VERSION;
	
	/** 购买数量 */
	private Integer quantity;

	/** 购买单价 */
	private Integer unitPrice;

	/** 购买总价 */
	private Integer totalPrice;

	/** 货号 */
	private String skuNo;
	
	/** 商品编号 */
	private String partNo;

	/** 商品名称 */
	private String name;

	/** 商品 */
	private DisGoods goods;

	/** 订单 */
	private DisOrder order;
	
	@ManyToOne
	@JoinColumn(name = "order_id")
	@Fetch(FetchMode.SELECT)
	@LazyToOne(LazyToOneOption.PROXY)
	public DisOrder getOrder() {
		return order;
	}

	@ManyToOne
	@JoinColumn(name = "goods_id")
	@Fetch(FetchMode.SELECT)
	@LazyToOne(LazyToOneOption.PROXY)
	public DisGoods getGoods() {
		return goods;
	}
}
